/*
 *  @product.title@
 *  Copyright (C) @product.copyright-year@
 *    @product.vendor@
 *    Registration Number: @product.registration-number@
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package jp.go.aist.six.util.xml;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import javax.xml.transform.Result;
import javax.xml.transform.Source;



/**
 * A prescription of the interface of the XML-Object mapping service.
 *
 * @author  Akihito Nakamura, AIST
 * @version $Id: XmlMapper.java 322 2011-11-04 11:05:34Z nakamura5akihito $
 */
public interface XmlMapper
{

    /**
     * Marshals the given object as XML to the specified output.
     *
     * @param   obj
     *  the object to marshal.
     * @param   result
     *  the result to marshal to.
     */
    public void marshal(
                    Object obj,
                    Result result
                    )
    throws XmlException;



    /**
     * Marshals the given object as XML to the specified output.
     *
     * @param   obj
     *  the object to marshal.
     * @param   stream
     *  the result to marshal to.
     */
    public void marshal(
                    Object obj,
                    OutputStream stream
                    )
    throws XmlException;



    /**
     * Marshals the given object as XML to the specified output.
     *
     * @param   obj
     *  the object to marshal.
     * @param   writer
     *  the result to marshal to.
     */
    public void marshal(
                    Object obj,
                    Writer writer
                    )
    throws XmlException;



    /**
     * Marshals the given object as XML and returns it as a string.
     *
     * @param   obj
     *  the object to marshal.
     * @return
     *  the marshalled XML as a string.
     */
    public String marshalToString(
                    Object obj
                    )
    throws XmlException;



    /**
     * Unmarshals the given XML source into an object.
     *
     * @param   source
     *  the source to unmarshal from.
     * @return
     *  the object.
     */
    public Object unmarshal(
                    Source source
                    )
    throws XmlException;



    /**
     * Unmarshals the given XML source into an object.
     *
     * @param   stream
     *  the source to unmarshal from.
     * @return
     *  the object.
     */
    public Object unmarshal(
                    InputStream stream
                    )
    throws XmlException;



    /**
     * Unmarshals the given XML source into an object.
     *
     * @param   reader
     *  the source to unmarshal from.
     * @return
     *  the object.
     */
    public Object unmarshal(
                    Reader reader
                    )
    throws XmlException;



    /**
     * Unmarshals the given XML string into an object.
     *
     * @param   xml
     *  the source XML string to unmarshal from.
     * @return
     *  the object.
     */
    public Object unmarshalFromString(
                    String xml
                    )
    throws XmlException;

}
// XmlMapper
